package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Certificate;
import com.hs.mapper.CertificateMapper;
import com.hs.service.CertificateService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CertificateServiceImpl implements CertificateService {
    @Autowired
    private CertificateMapper certificateMapper;
    @Override
    public Integer addCertificate(Certificate certificate) {
        return certificateMapper.addCertificate(certificate);
    }

    @Override
    public Integer deleteCertificate(Integer id) {
        return certificateMapper.deleteCertificate(id);
    }

    @Override
    public Integer updateCertificate(Certificate certificate) {
        return certificateMapper.updateCertificate(certificate);
    }

    @Override
    public Certificate getCertificateById(Integer id) {
        return certificateMapper.getCertificateById(id);
    }

    @Override
    public PageInfo<Certificate> getCertificateByPages(Certificate certificate, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Certificate> certificateByPage = certificateMapper.getCertificateByPage(certificate);
        PageInfo<Certificate> pageInfo = new PageInfo<>(certificateByPage);
        return pageInfo;
    }

}
